(1) Field of the Invention
This invention relates to an image encoding apparatus and an image encoding method which perform an orthogonal transformation, quantization, and entropy coding, and relates to a recording medium in which an image encoding program is recorded.
(2) Description of the Prior Art
Recently, great efforts have been made to develop efficient techniques for coding/compressing images. Among these techniques, JPEG is an international standard for coding and decoding still pictures; MPEG1 Video is an international standard for coding and decoding moving pictures.
According to these image coding/compressing methods, images are encoded and converted into compressed data as follows. Image data is first divided into blocks. Each block is subjected to an orthogonal transformation process to output orthogonal transformation coefficients. The obtained orthogonal transformation coefficients are subjected to a quantization process to output quantized orthogonal transformation coefficients. The obtained quantized orthogonal transformation coefficients are entropy-encoded, resulting in variable-length encoded/compressed data.
Digital still cameras, digital video cassette recorders and the like have been developed using such image compressing techniques. These products have their own numbers of recordable images or recording times. However, in case of variable-length encoding methods, the assigned number of recordable images or the assigned recording time may not be ensured since the amount of encoded data for each image is different from each other.
The following method is known as a method of ensuring the assigned number of recordable images or the assigned recording time. According to this method, quantization widths used for the quantization process are temporarily determined. Using the determined quantization widths, the quantization process and the subsequent processes are performed as described earlier. In doing so, a total amount of encoded data of an image is compared to a target encode amount of the image to predict a suitable quantization width for achieving an amount which is close to the target amount. When the predicted quantization width is close to a quantization width of the preceding image encoding and when the current total encode amount is less than a target encode amount, the variable-length encode data is output. Otherwise, another quantization width is used to repeat the same processes.
Japanese Laid-Open Patent Application No.4-207266 xe2x80x9cImage Data Encoding Apparatus and Methodxe2x80x9d discloses an encoding/compressing method in which different quantization tables for respective colors are used to encode/compress color images. With this construction, it is possible for this method to encode each image in a certain process time by assigning a different encode amount for each color and each block.
However, the former method has a problem that each encoding takes a different encode time, and that each encoding takes a long time since the encode process is repeated at least twice, though each encode amount is equal to or less than a target amount.
Also, the latter method has a problem that each encoding takes a long time since the encode process is repeated at least twice, though a constant encode time is kept.
It is therefore an object of the present invention to provide an image encoding apparatus, an image encoding method, and a recording medium storing an image encoding program which encode an image with a certain process time so that a certain error or less is produced between the generated encode amount and a target encode amount, that is, use a less process time than conventional ones and obtain a high-quality image.
The above object is achieved by an image encoding apparatus for generating encoded images which have encode amounts close to corresponding target encode amounts, the image encoding apparatus comprising: a relationship storage unit for storing relationships, for each of one or more standard images, between a group of a plurality of quantization widths and one or more groups of a plurality of encode amounts, where each of the one or more groups of the plurality of encode amounts is obtained by encoding each of the one or more standard images using the plurality of quantization widths respectively; a quantization width determining unit for obtaining a target encode amount and referring to the relationship storage unit to obtain one or more quantization widths which correspond to one or more encode amounts which each are closest to the obtained target encode amount in a corresponding one of the one or more groups of the plurality of encode amounts; and an encoding unit for obtaining an image and encoding the obtained image using the one or more quantization widths obtained by the quantization width determining unit.
With the above construction, it is possible to have an effect that each image is encoded with an encode amount close to the target encode amount since each image is encoded with a quantization width which corresponds to an encode amount closest to the target encode amount in the relationships the apparatus holds.
In the above image encoding apparatus, the encoding unit may include: a predicted encode amount calculating unit for obtaining an image, generating one or more quantization tables using the one or more quantization widths obtained by the quantization width determining unit, and calculating one or more predicted encode amounts for the obtained image using the generated one or more quantization tables; an optimum quantization width determining unit for reading the relationships from the relationship storage unit, obtaining a quantization width corresponding to the target encode amount using the one or more predicted encode amounts and using the read relationships, and determining the obtained quantization width as the optimal quantization width; and an image encoding unit for generating a quantization table using the optimal quantization width, and encoding the obtained image using the generated quantization table.
With the above construction, it is possible to have an effect that each image is encoded with an encode amount closer to the target encode amount than before since one or more predicted encode amounts are calculated using the one or more quantization tables, a quantization width corresponding to the target encode amount is obtained using the one or more predicted encode amounts and using the read relationships, the obtained quantization width is determined as the optimal quantization width, and the image is encoded with the optimal quantization width.
In the above image encoding apparatus, each image to be obtained by the encoding unit may include a plurality of block groups which each include a predetermined number of blocks, and the image obtaining unit obtains a predetermined number of blocks from predetermined positions in each of the plurality of block groups.
With the above construction, it is possible to have an effect that the process time is reduced since a smaller amount of image data is read to be used for predicting the relationship between the quantization width and the encode amount.
In the above image encoding apparatus, each image to be obtained by the encoding unit may include a plurality of block groups which each include a predetermined number of blocks, each block includes a predetermined number of pixels, and the image obtaining unit obtains a predetermined number of pixels from predetermined positions in each of the plurality of block groups.
With the above construction, it is possible to have an effect that the process time is reduced since a smaller amount of image data is read to be used for predicting the relationship between the quantization width and the encode amount. It is also possible to have an effect that the relationship between the quantization width and the encode amount is predicted accurately even if the current block has an edge component since pixels are selected at certain intervals (e.g., on a one-out-of-four basis), the edge component is a portion having a radical change of an image.
In the image encoding apparatus, each of the one or more quantized orthogonal transformation images generated by the quantization unit may include a plurality of blocks, each block includes one direct current component coefficient and (nxe2x88x921) alternating current component coefficients, the predetermined formula used by the predicted encode amount calculating unit is represented as:             V      e        =                            α          dc                *                  log          2                ⁢                  xe2x80x83                ⁢                  "LeftBracketingBar"                      S            q0                    "RightBracketingBar"                    +                        α          ac                *                              ∑                          i              =              1                                      n              -              1                                ⁢                      xe2x80x83                    ⁢                      L            ⁡                          (                              S                qi                            )                                          +                        α          zn                *                              ∑                          i              =              1                                      n              -              1                                ⁢                      xe2x80x83                    ⁢                      d            ⁡                          (                              S                qi                            )                                          +      β        ,
where
Ve represents a predicted encode amount of one block,
n represents the number of pixels included in one block,
Sq0 represents a difference between quantized orthogonal transformation coefficients (direct current components) of the current and preceding blocks,
Sqi represents a quantized orthogonal transformation coefficient (alternating current component, where i=xe2x80x9c1xe2x80x9d to xe2x80x9c63xe2x80x9d),
xcex1dc represents a conversion coefficient,
xcex1ac represents a conversion coefficient,
xcex1zn represents a conversion coefficient,
xcex2 represents a constant,
L(X) represents a function which provides a result value xe2x80x9c0xe2x80x9d when X=0 and a result value of log2|X| when Xxe2x89xa00, and
d(X) represents a function which provides a result value xe2x80x9c0xe2x80x9d when X=0 and a result value xe2x80x9c1xe2x80x9d when Xxe2x89xa00.
With the above construction, it is possible to have an effect that the process time is reduced since the encode amount is predicted without performing the variable-length encoding.
In the above image encoding apparatus, the relationship storage unit may store a first group of a plurality of encode amounts and a second group of a plurality of encode amounts, where the plurality of encode amounts of each of the first and second groups respectively correspond to the plurality of quantization widths, the quantization width determining unit obtains a quantization width xcex1e1 and a quantization width xcex1e2, the predicted encode amount calculating unit calculates a predicted encode amount Vp1 and a predicted encode amount Vp2 respectively using the quantization width xcex1e1 and the quantization width xcex1e2, the optimum quantization width determining unit include: an encode amount obtaining unit for obtaining a first encode amount Vb1 and a second encode amount Va1 corresponding to the quantization width xcex1e1 and obtaining a first encode amount Vb2 and a second encode amount Va2 corresponding to the quantization width xcex1e2; and a quantization width calculating unit for calculating a target encode amount using the following formula:             V      q        =                  V        a            +                        {                                                                      V                  p1                                -                                  V                  a1                                                                              V                  b1                                -                                  V                  a1                                                      +                                          (                                                                                                    V                        p2                                            -                                              V                        a2                                                                                                            V                        b2                                            -                                              V                        a2                                                                              -                                                                                    V                        p1                                            -                                              V                        a1                                                                                                            V                        b1                                            -                                              V                        a1                                                                                            )                            *                                                                    α                    q                                    -                                      α                    e1                                                                                        α                    e2                                    -                                      α                    e1                                                                                }                *                  (                                    V              b                        -                          V              a                                )                      ,
where Vq represents an encode amount of an image generated with an arbitrary quantization width xcex1q, and determining a quantization width corresponding to the calculated target encode amount as an optimum quantization width, where a second encode amount corresponding to the arbitrary quantization width xcex1q is obtained from the relationship storage unit and the obtained second encode amount is regarded as Va, and a first encode amount corresponding to the arbitrary quantization width xcex1q is obtained from the relationship storage unit and the obtained first encode amount is regarded as Vb.
With the above construction, it is possible to have an effect that the relationship between the quantization width and the encode amount is predicted more accurately than before since an image with a large encode amount and an image with a small encode amount are encoded with a certain number of quantization widths to obtain the first and second encode amounts. The obtained first and second encode amounts are used together with the quantization widths and read image to predict the relationship between the quantization width and the encode amount.
In the above image encoding apparatus, each image to be obtained by the encoding unit may include a plurality of blocks which each include a predetermined number of pixels, the optimum quantization width determining unit obtains a predicted encode amount corresponding to the optimum quantization width, the image encoding unit includes: a block-assignment encode amount calculating unit for obtaining a block of the obtained image, generating a quantization table using the optimum quantization width based on the predicted encode amount and the target encode amount, and calculating a block-assignment encode amount for the obtained block using the one or more quantization tables generated by the predicted encode amount calculating unit; a block encoding unit for generating a quantization table using the optimum quantization width and encoding each block using the generated quantization table so that an encode amount of the obtained block does not exceed the block-assignment encode amount.
With the above construction, it is possible to have an effect that the performance of the compression/encoding is improved since it is possible to encode the image with a certain error or less between the generated encode amount and the target encode amount with only one encoding by predicting the encode amount, while in conventional techniques, the encoding process is performed at least once to check the generated encode amount of the image.
In the above image encoding apparatus, the block-assignment encode amount calculating unit may include: an image obtaining unit for obtaining a block of the obtained image; an orthogonal transformation unit for performing an orthogonal transformation on the obtained block to generate an orthogonal transformation block; a quantization unit for quantizing the orthogonal transformation block using the one or more quantization tables to generate one or more quantized orthogonal transformation blocks; a block predicted encode amount calculating unit for calculating a predicted encode amount of the obtained block using the one or more quantized orthogonal transformation blocks; and a secondary block-assignment encode amount calculating unit for calculating a block-assignment encode amount by substituting into a predetermined formula the one or more predicted encode amounts for the obtained image, the target encode amount, and the predicted encode amount of the obtained block.
With the above construction, it is possible to have an effect that the encode amount of the entire image does not exceed the target encode amount since the block-assignment encode amount is determined for each block for this purpose and each block is encoded not to exceed the block-assignment encode amount.
In the above image encoding apparatus, the block-assignment encode amount calculating unit may include: an image obtaining unit for obtaining a block of the obtained image; an orthogonal transformation unit for performing an orthogonal transformation on the obtained block to generate an orthogonal transformation block; a quantization unit for generating a quantization table, and quantizing the orthogonal transformation block to generate a quantized orthogonal transformation block; an entropy-encoding unit for encoding the quantized orthogonal transformation block so that the quantized orthogonal transformation block does not exceed the block-assignment encode amount.
With the above construction, it is possible to have an effect that the encode amount of the entire image does not exceed the target encode amount since the block-assignment encode amount is determined for each block for this purpose and each block is encoded not to exceed the block-assignment encode amount.